<template>
	<!-- <view class="index-container">
		<view class="nav">
			<view class="nav-item" v-for="(item, index) in serveList" :key="index" @click="goTicket(item.path)">
				<view class="item-img">
					<image :src="item.src" mode=""></image>
				</view>
				<text>{{item.title}}</text>
			</view>
			<view v-if="gridInfo" class="nav-item" @click="goTicket('/fireGridCheck/index/index')">
				<view class="item-img">
					<image src="../../static/new/54.png" mode=""></image>
				</view>
				<text>网格管理</text>
			</view>
		</view>
	</view> -->
	<view>
		<view class="search-container">
			<van-search @change="handleChange" :value="value" placeholder="请输入搜索关键词" show-action @search="onSearch"
				/>
		</view>
		<view v-if="!value" style="padding-bottom: 40rpx;">
			<view class="banner-img">
				<image src="../../static/serve.png"></image>
			</view>
			<view v-for="(item,index) in menuList" class="grid-container">
				<view class="grid-title">{{item.title}}</view>
				<view class="grid-box">
					<view @click="goService(index, subIndex)" v-for="(subItem,subIndex) in item.list" class="grid-item">
						<view class="grid-img">
							<image :src="subItem.src" />
						</view>
						<text>{{subItem.title}}</text>
					</view>
				</view>
			</view>
		</view>
		<view v-else>
			<view v-if="searchList.length" class="grid-container">
				<view class="grid-box">
					<view @click="goServe(item.path)" v-for="(item, index) in searchList" class="grid-item">
						<view class="grid-img">
							<image :src="item.src" />
						</view>
						<text>{{item.title}}</text>
					</view>
				</view>
			</view>
			<view style="height: 90vh;background-color: #fff;"  v-else>
				<van-empty description="暂无服务"></van-empty>
			</view>
		</view>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				searchList: [],
				value: '',
				menuList: [{
					title: '工单管理',
					list: [{
							src: '../../static/service/1.png',
							title: '工单列表',
							path: '/ticketSystem/index/index'
						},
						{
							src: '../../static/service/2.png',
							title: '事件上报',
							path: '/ticketSystem/createOrder/createOrder'
						},
						{
							src: '../../static/service/3.png',
							title: '上报记录',
							path: '/ticketSystem/myTicket/myTicket'
						},
						{
							src: '../../static/service/4.png',
							title: '工单统计',
							path: '/ticketSystem/statistic/statistic'
						},
						{
							src: '../../static/service/5.png',
							title: '自主接单',
							path: '/ticketSystem/acceptTicket/acceptTicket'
						},
						{
							src: '../../static/service/6.png',
							title: '自主派发',
							path: '/ticketSystem/assignTicket/assignTicket'
						},
						{
							src: '../../static/service/7.png',
							title: '延期审批',
							path: '/ticketSystem/delayApply/delayApply'
						}
					]
				}, {
					title: '任务管理',
					list: [{
						src: '../../static/service/8.png',
						title: '巡逻任务',
						path: '/taskSystem/list/list?type=2'
					}, {
						src: '../../static/service/9.png',
						title: '设备巡检',
						path: '/taskSystem/list/list?type=3'
					}, {
						src: '../../static/service/10.png',
						title: '品质巡检',
						path: '/taskSystem/list/list?type=4'
					},{
						src: '../../static/service/24.png',
						title: '我参与的',
						path: '/taskSystem/list/list?type=join'
					},{
						src: '../../static/service/25.png',
						title: '我创建的',
						path: '/taskSystem/list/list?type=create'
					}]
				}, {
					title: '物料管理',
					list: [{

							src: '../../static/service/11.png',
							title: '物料申领',
							path: '/materialSystem/materialApply/materialApply'
						},
						{
							src: '../../static/service/12.png',
							title: '物料采购',
							path: '/materialSystem/materialPurchase/materialPurchase'
						},
						{
							src: '../../static/service/13.png',
							title: '物料退回',
							path: '/materialSystem/materialEmerge/materialEmerge'
						}, {
							src: '../../static/service/14.png',
							title: '申请记录',
							path: '/materialSystem/applyRecord/applyRecord'
						}, {
							src: '../../static/service/15.png',
							title: '我的物料',
							path: '/materialSystem/myMaterial/myMaterial'
						}
					]
				}, {
					title: '入户管理',
					// {
					// 	src: '../../static/service/16.png',
					// 	title: '入户登记',
					// 	path: '/roomSystem/checkRoomList/checkRoomList'
					// },
					list: [{
						src: '../../static/service/17.png',
						title: '入户列表',
						path: '/roomSystem/checkRoomList/checkRoomList'
					}]
				}, {
					title: '装修管理',
					list: [{
						src: '../../static/service/18.png',
						title: '装前检查',
						path: '/renovationSystem/frontInspect/frontInspect'
					}, {
						src: '../../static/service/19.png',
						title: '装修巡场',
						path: '/renovationSystem/endCheck/endCheck'
					}, {
						src: '../../static/service/20.png',
						title: '装后检查',
						path: '/renovationSystem/endInspect/endInspect'
					}]
				}, {
					title: '考核管理',
					list: [{
						src: '../../static/service/21.png',
						title: '考核列表',
						path: '/assessSystem/assessList/assessList'
					}, {
						src: '../../static/service/22.png',
						title: '考核工作',
						path: '/assessSystem/assessWork/assessWork'
					}, {
						src: '../../static/service/23.png',
						title: '考核统计',
						path: '/assessSystem/assessStatic/assessStatic'
					}]
				}],
				allList: [{
						src: '../../static/service/1.png',
						title: '工单列表',
						path: '/ticketSystem/index/index'
					},
					{
						src: '../../static/service/2.png',
						title: '事件上报',
						path: '/ticketSystem/createOrder/createOrder'
					},
					{
						src: '../../static/service/3.png',
						title: '上报记录',
						path: '/ticketSystem/myTicket/myTicket'
					},
					{
						src: '../../static/service/4.png',
						title: '工单统计',
						path: '/ticketSystem/statistic/statistic'
					},
					{
						src: '../../static/service/5.png',
						title: '自主接单',
						path: '/ticketSystem/acceptTicket/acceptTicket'
					},
					{
						src: '../../static/service/6.png',
						title: '自主派发',
						path: '/ticketSystem/assignTicket/assignTicket'
					},
					{
						src: '../../static/service/7.png',
						title: '延期审批',
						path: '/ticketSystem/delayApply/delayApply'
					}, {
						src: '../../static/service/8.png',
						title: '巡逻任务',
						path: '/taskSystem/list/list'
					}, {
						src: '../../static/service/9.png',
						title: '设备巡检',
						path: '/taskSystem/list/list'
					}, {
						src: '../../static/service/10.png',
						title: '品质巡检',
						path: '/taskSystem/list/list'
					}, {
						src: '../../static/service/11.png',
						title: '物料申领',
						path: '/materialSystem/materialApply/materialApply'
					},
					{
						src: '../../static/service/12.png',
						title: '物料采购',
						path: '/materialSystem/materialPurchase/materialPurchase'
					},
					{
						src: '../../static/service/13.png',
						title: '物料退回',
						path: '/materialSystem/materialEmerge/materialEmerge'
					}, {
						src: '../../static/service/14.png',
						title: '申请记录',
						path: '/materialSystem/applyRecord/applyRecord'
					}, {
						src: '../../static/service/15.png',
						title: '我的物料',
						path: '/materialSystem/myMaterial/myMaterial'
					},
					{
						src: '../../static/service/16.png',
						title: '入户登记',
						path: '/roomSystem/checkRoomList/checkRoomList'
					}, {
						src: '../../static/service/17.png',
						title: '入户列表',
						path: '/roomSystem/checkRoomList/checkRoomList'
					}, {
						src: '../../static/service/18.png',
						title: '装前检查',
						path: '/renovationSystem/frontInspect/frontInspect'
					}, {
						src: '../../static/service/19.png',
						title: '装修巡场',
						path: '/renovationSystem/endCheck/endCheck'
					}, {
						src: '../../static/service/20.png',
						title: '装后检查',
						path: '/renovationSystem/endInspect/endInspect'
					},
					{
						src: '../../static/service/21.png',
						title: '考核列表',
						path: '/assessSystem/assessList/assessList'
					}, {
						src: '../../static/service/22.png',
						title: '考核工作',
						path: '/assessSystem/assessWork/assessWork'
					}, {
						src: '../../static/service/23.png',
						title: '考核统计',
						path: '/assessSystem/assessStatic/assessStatic'
					}
				],
				ticketList: [{
						src: '../../static/service/1.png',
						title: '报事工单',
						path: '/ticketSystem/index/index'
					},
					{
						src: '../../static/service/2.png',
						title: '计划任务',
						path: '/taskSystem/index/index'
					},
					{
						src: '../../static/service/3.png',
						title: '设备管理',
						path: '/ticketSystem/clean/clean'
					},
					{
						src: '../../static/service/4.png',
						title: '设备管理',
						path: '/ticketSystem/clean/clean'
					},
					{
						src: '../../static/service/5.png',
						title: '设备管理',
						path: '/ticketSystem/clean/clean'
					},
					{
						src: '../../static/service/6.png',
						title: '设备管理',
						path: '/ticketSystem/clean/clean'
					},
					{
						src: '../../static/service/7.png',
						title: '设备管理',
						path: '/ticketSystem/clean/clean'
					}
				],

				value: '',
				serveList: [{
						src: '../../static/new/37.png',
						title: '报事工单',
						path: '/ticketSystem/index/index'
					},
					{
						src: '../../static/new/38.png',
						title: '计划任务',
						path: '/taskSystem/index/index'
					}, {
						src: '../../static/new/39.png',
						title: '设备管理',
						path: '/ticketSystem/clean/clean'
					},
					{
						src: '../../static/new/35.png',
						title: '物料管理',
						// path: ''
						path: '/materialSystem/index/index'
					},
					{
						src: '../../static/new/36.png',
						title: '入户管理',
						path: '/ticketSystem/firecontrol/firecontrol'
					}, {
						src: '../../static/new/41.png',
						title: '投诉管理',
						path: '/ticketSystem/feedback/feedback'
					},
					{
						src: '../../static/new/42.png',
						title: '活动管理',
						path: '/roomSystem/checkRoomList/checkRoomList'
					},
					{
						src: '../../static/new/43.png',
						title: '装修管理',
						// path: ''
						path: '/renovationSystem/index/index'
					},
					{
						src: '../../static/new/44.png',
						title: '访客管理',
						// path: ''
						path: '/assessSystem/index/index'
					},

				]
			}
		},
		created() {
			// uni.showTabBar()
		},
		onLoad() {
			this.getGroupInfo()
		},
		onHide() {
			this.value = ''
		},
		computed: {
			gridInfo() {
				return uni.getStorageSync('gridInfo')
			}
		},
		methods: {
			goServe(url) {
				uni.navigateTo({
					url
				})
			},
			handleChange(event) {
				console.log(event)
				console.log(this.value)
				this.value = event.detail
				this.searchList = this.allList.filter(item => item.title.includes(this.value))
			},
			getGroupInfo() {
				this.$http.post('/sys/group/info', {
					id: this.$config.groupId
				}).then(res => {
					if (res.code === 10000) {
						uni.setStorageSync('groupName', res.data.name)
					}
				})
			},
			goService(index, subIndex) {
				uni.navigateTo({
					url: this.menuList[index].list[subIndex].path
				})
				console.log(index, subIndex)
			},
			goTicket(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F5F5F5;
	}

	.grid-container {
		width: 702rpx;
		margin-bottom: 20rpx;
		margin-left: 24rpx;
		background: #fff;
		border-radius: 12rpx;

		.grid-title {
			font-size: 32rpx;
			font-weight: bold;
			padding: 20rpx;
		}

		.grid-box {
			display: flex;
			flex-wrap: wrap;
			padding: 24rpx 12rpx 10rpx 0;
		}

		.grid-item {
			flex: 0 0 25%;
			display: flex;
			padding: 0 10rpx;
			margin-bottom: 30rpx;
			flex-direction: column;
			align-items: center;

			.grid-img {
				width: 100rpx;
				height: 100rpx;
				margin-bottom: 22rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}

	.grid-item {
		text {
			font-size: 28rpx;
		}
	}


	.search-container {
		padding: 20;
		background-color: #F5F5F5;
	}

	.banner-img {
		width: 702rpx;
		height: 270rpx;
		margin-left: 24rpx;
		margin-bottom: 20rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.index-container {
		background-color: #F5f5f5;
		height: 100vh;

		.banner {
			width: 750rpx;
			height: 360rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.nav {
			margin-top: 26rpx;
			// position: relative;
			// left: 20rpx;
			// top: -50rpx;
			width: 702rpx;
			height: 936rpx;
			background: #F7F7F7;
			box-shadow: 0px 2rpx 16rpx 0px #E0E6EF;
			border-radius: 12rpx;
			display: flex;
			flex-wrap: wrap;
			margin-left: 24rpx;

			.nav-item {
				width: 234rpx;
				height: 234rpx;
				text-align: center;
				overflow: hidden;
				border: 2rpx solid #eee;

				.item-img {
					width: 90rpx;
					height: 90rpx;
					margin: 55rpx 86rpx 23rpx 66rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}
		}
	}
</style>
